package cn.aresoft.configuration;


import cn.aresoft.excel.handle.ICellStyleSelfDefineHandler;
import cn.aresoft.excel.handle.IDictListGetHandler;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "spring.my-poi")
@Getter
public class PoiConfigProperties {

    private IDictListGetHandler dictListGetHandler;

    private ICellStyleSelfDefineHandler cellStyleSelfDefineHandler;

    private Integer threadCoreSize;

    private Integer threadMaxSize;

    private Integer blockingQueueSize;

    private Integer batchDealSize;



    public void setDictListGetHandler(String dictListGetHandler) throws Exception {
        if(StringUtils.isNotEmpty(dictListGetHandler)){
            this.dictListGetHandler = (IDictListGetHandler) Class.forName(dictListGetHandler).newInstance();
        }
    }

    public void setCellStyleSelfDefineHandler(String cellStyleSelfDefineHandler) throws Exception {
        if(StringUtils.isNotEmpty(cellStyleSelfDefineHandler)){
            this.cellStyleSelfDefineHandler = (ICellStyleSelfDefineHandler) Class.forName(cellStyleSelfDefineHandler).newInstance();
        }
    }

    public void setThreadCoreSize(Integer threadCoreSize) {
        this.threadCoreSize = threadCoreSize;
    }

    public void setThreadMaxSize(Integer threadMaxSize) {
        this.threadMaxSize = threadMaxSize;
    }

    public void setBatchDealSize(Integer batchDealSize) {
        this.batchDealSize = batchDealSize;
    }

    public void setBlockingQueueSize(Integer blockingQueueSize) {
        this.blockingQueueSize = blockingQueueSize;
    }
}
